package com.electromagnetic.industry.software.manage.controller;

import com.electromagnetic.industry.software.common.annotations.UserOperation;
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.manage.service.FileFormatService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/data/ed/file/format")
public class FileFormatController {

    @Resource
    private FileFormatService fileFormatService;

    @GetMapping("/add")
    @UserOperation(value = "新增文件格式", modelName = UserOperationModuleEnum.FILE_FORMAT)
    public ElectromagneticResult<?> addFileFormat(@RequestParam String suffixName) {
        return ElectromagneticResultUtil.success(fileFormatService.addFileFormat(suffixName));
    }

    @GetMapping("/delete")
    @UserOperation(value = "删除文件格式", modelName = UserOperationModuleEnum.FILE_FORMAT)
    public ElectromagneticResult<?> deleteFileFormat(@RequestParam String id) {
        return ElectromagneticResultUtil.success(fileFormatService.deleteFileFormat(id));
    }

    @GetMapping("/list")
    @UserOperation(value = "查询文件格式列表", modelName = UserOperationModuleEnum.FILE_FORMAT)
    public ElectromagneticResult<?> list() {
        return ElectromagneticResultUtil.success(fileFormatService.getList());
    }

}
